﻿Imports System.Xml
Imports System.Xml.Serialization
Imports System.IO

Public Class CountryCodeUtilities
    Public Shared Function getCountryCodes() As IEnumerable(Of CountryCode)

        'Return Nothing

        Dim asm = System.Reflection.Assembly.GetExecutingAssembly()
        'My.Resources.
        Dim r = asm.GetManifestResourceStream(GetType(CountryCodeUtilities), "iso_3166-1_list_en.xml")
        Dim ser As New XmlSerializer(GetType(ListLoader))

        Dim loader = ser.Deserialize(r)
        Return DirectCast(loader, ListLoader).CCodes
    End Function


    <XmlRoot("ISO_3166-1_List_en")>
    Public Class ListLoader
        <XmlElement("ISO_3166-1_Entry")> Public Property CCodes As List(Of CountryCode)
    End Class
End Class

<XmlRoot("ISO_3166-1_Entry")>
Public Class CountryCode
    <XmlElement("ISO_3166-1_Country_name")> Public Property Name As String
    <XmlElement("ISO_3166-1_Alpha-2_Code_element")> Public Property Code As String
End Class